package com.cheli.oss.controller;

import com.cheli.commonutils.R;
import com.cheli.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.FileNotFoundException;

/**
 * @Auther: cl
 * @Date: 2020/10/22 15:05
 * @Description:
 */
@RestController
@RequestMapping("/oss/fileoss")
@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

   @PostMapping
    public R uploadOssFile(MultipartFile file){
       //返回上传到OSS的路径
        String url = ossService.uploadFileAvatar(file);

        return R.ok().data("url",url);
    }
}
